package com.yjt.fresh.adpater;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yjt.fresh.R;
import com.yjt.fresh.activity.AtyApplyBack;
import com.yjt.fresh.bean.BeanOrder;
import com.yjt.fresh.constant.MyConstants;
import com.yjt.fresh.utils.CommonsToolsHelper;
import com.yjt.fresh.widget.ScrollLinearLayoutManager;

import java.util.List;

/**
 * Created by UPC on 2018/8/16.
 */

public class AdpRvFrgAfterSaleApply extends BaseQuickAdapter<BeanOrder, BaseViewHolder> {


    public AdpRvFrgAfterSaleApply(int layoutResId, List<BeanOrder> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final BeanOrder item) {

        TextView mTvOrderNum = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleApplyHeadOrderNum);

        TextView mTvTime = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleApplyHeadTime);

        RecyclerView mRv = helper.getView(R.id.rvAppRecycleItemFrgAfterSaleApplyHead);
        ViewGroup.LayoutParams layoutParams = mRv.getLayoutParams();
        layoutParams.width = RecyclerView.LayoutParams.MATCH_PARENT;
        layoutParams.height = item.getGOODS().size() * CommonsToolsHelper.dip2px(mContext,121);
        mRv.setLayoutParams(layoutParams);
        mTvOrderNum.setText("订单编号:"+item.getORDERS_ID());
        mTvTime.setText(item.getRECEIVER_TIME());
        ScrollLinearLayoutManager manager = new ScrollLinearLayoutManager(mContext);
        manager.setAutoMeasureEnabled(true);
        mRv.setLayoutManager(manager);
        mRv.setHasFixedSize(true);
        mRv.setNestedScrollingEnabled(false);
        AdpRvFrgAfterSaleApplyChild adpChild = new AdpRvFrgAfterSaleApplyChild(R.layout.app_recycle_item_frg_after_sale_apply_content,item.getGOODS());
        mRv.setAdapter(adpChild);
        adpChild.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent = new Intent(mContext, AtyApplyBack.class);
                intent.putExtra(MyConstants.TOTAL_MONEY,item.getTOTALPAY());
                intent.putExtra(MyConstants.GOODS_OBJ,item.getGOODS().get(position));
                mContext.startActivity(intent);
            }
        });
    }
}
